#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include <limits.h>
#include <ctype.h>

#define ROOK	0x1
#define BISHOP	0x2
typedef int int8x8[8][8];

const static int rook_dir_i[4]		= { -1, 1, 0, 0 };
const static int rook_dir_j[4]		= { 0, 0, -1, 1 };

const static int bishop_dir_i[4]	= { 1, -1, -1, 1 };
const static int bishop_dir_j[4]	= { 1, -1, 1, -1 };

struct chessboard {
	int8x8 fig;
	int8x8 covered;
};

int
mark_covered_squares(struct chessboard *c)
{
	int i, j, ans = 0, d;
	int I, J;

	for (i = 0; i < 8; i++)
		for (j = 0; j < 8; j++)
			if (c->fig[i][j] == ROOK) {
				for (d = 0; d < 4; ++d) {
					I = i + rook_dir_i[d];
					J = j + rook_dir_j[d];
					while (I >= 0 && I < 8 && J >= 0 && J < 8 &&
							c->covered[I][J] != 2) {
						c->covered[I][J] = 1;
						I += rook_dir_i[d];
						J += rook_dir_j[d];
					}
				}
			} else if (c->fig[i][j] == BISHOP) {
				for (d = 0; d < 4; ++d) {
					I = i + bishop_dir_i[d];
					J = j + bishop_dir_j[d];
					while (I >= 0 && J >= 0 && I < 8 && J < 8 &&
							c->covered[I][J] != 2) {
						c->covered[I][J] = 1;
						I += bishop_dir_i[d];
						J += bishop_dir_j[d];
					}
				}
			}

	for (i = 0; i < 8; i++)
		for (j = 0; j < 8; j++)
			if (c->covered[i][j])
				++ans;

	return 64 - ans;
}

int
main(int argc, char **argv)
{
	static struct chessboard c;
	char ch, prev = '\0';
	int i, j;

	i = 0, j = 0;
	while (ch = fgetc(stdin), ch != EOF) {
		switch (ch) {
		case '*':
			j++;
			break;
		case 'R': case 'r':
			c.fig[i][j] = ROOK;
			c.covered[i][j] = 2;
			j++;
			break;
		case 'B': case 'b':
			c.fig[i][j] = BISHOP;
			c.covered[i][j] = 2;
			j++;
			break;
		default:
			fprintf(stderr, "i=%d j=%d unexpected character \'%c\'\n",
					i, j, ch);
		case '\n': case ' ':
			if (prev != ' ' && prev != '\n') {
				i++;
				j = 0;
			}
			break;
		}

		prev = ch;

		if (j > 8 || i > 8) {
			fprintf(stderr, "WARNING: %s has encountered expected error\n",
					argv[0]);
		}
	}

	printf("%d\n", mark_covered_squares(&c));

	return 0;
}
